package com.example.test.advice.第六章_枚举和注解.建议85_小心switch带来的空值异常;

public class Client {

    public static void main(String[] args) {
        doSports(Season.Spring);
    }

    public static void doSports(Season season){
        System.out.println(season.ordinal());//输出枚举的编号
        if(season == null){
            System.out.println("输入有误，不能为null");
            return;
        }
        switch (season){
            case Spring:
                System.out.println("春天放风筝");
                break;
            case Summer:
                System.out.println("夏天游泳");
                break;
            case Autumn:
                System.out.println("秋天捉知了");
                break;
            case Winter:
                System.out.println("冬天滑冰");
                break;
            default:
                System.out.println("输入错误！");
                break;
        }
    }
}
